package org.dbstar.scheduler.control.db.catalog;

import org.dbstar.scheduler.beans.Catalog;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;


/**
 * 快速插入Catalog对象
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-4-21
 */
public class CatalogInsert extends SimpleJdbcInsert {
	public CatalogInsert(JdbcTemplate jdbcTemplate) {
		super(jdbcTemplate);
		withTableName("SCHD_CATALOG");
		usingColumns("NAME", "PARENT", "DESCRIPTION", "CREATE_TIME", "OWNER");
		usingGeneratedKeyColumns("ID");
	}

	public int insertCatalog(Catalog info) {
		BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(info);
		return super.executeAndReturnKey(source).intValue();
	}
}
